# Maintainer: David Runge <dvzrv@archlinux.org>

_name=pywayland
pkgname=python-pywayland
pkgver=0.4.15
pkgrel=2
pkgdesc="Python bindings for the libwayland library"
arch=(loong64 x86_64)
url="https://github.com/flacjacket/pywayland"
license=(Apache)
depends=(python-cffi wayland)
makedepends=(python-build python-installer python-setuptools wayland-protocols python-wheel)
checkdepends=(python-pytest)
source=(https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz)
sha512sums=('56973831b26ebbb53dc5b717129a7184b3d3f7354a62b6176eafa49889c1f46b53398f8e88bb8eb3c1d3068c543f1821532889fee337fc83061234a3ec1b2549')
b2sums=('1930e9effd7557fcf257c6b3eefa158d808ea5f19d8a2112e09083d4207d34c9dad50fa2f94d4d12c6afa1bb0753a1ebb8722aa3f601410c4ce9925862e437a5')

build() {
  cd $_name-$pkgver
  python pywayland/ffi_build.py
  python -m pywayland.scanner
  python -m build --wheel --no-isolation
}

check() {
  local _py_ver="$(python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')"

  cd $_name-$pkgver
  mkdir -vp temp
  export PYTHONPATH="build/lib.linux-$CARCH-$_py_ver:$PYTHONPATH"
  export XDG_RUNTIME_DIR="$PWD/temp"
  pytest -vv
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 README.rst -t "$pkgdir/usr/share/doc/$pkgname"
}
